/**
 * 
 */
package cn.edu.hstc.ui;

import android.net.http.AndroidHttpClient;
import android.os.Bundle;
import android.view.View;
import cn.edu.hstc.R;
import cn.edu.hstc.common.HttpUtils;
import cn.edu.hstc.common.L;

/**
 * @Description 教务系统主界面
 * @author act262
 * @version 1.0
 * @since 2014-4-30 下午5:36:57
 * 
 */
public class JwglMain extends BaseActivity {

	/** 公用 httpClient */
	public static AndroidHttpClient sHttpClient;

	/** intent action */
	public static final String JWGL_CONTENT_INTENT_TYPE = "cn.edu.hstc.intent.action.JWGL_CONTENT_TYPE";
	public static final String JWGL_CONTENT_INTENT_DATA = "cn.edu.hstc.intent.action.JWGL_CONTENT_DATA";

	/**
	 * @Description 教务系统使用的内容类型
	 */
	public enum JwglContentType {
		/** 用户信息 */
		UserInfo,
		/** 课程表 */
		Schedule,
		/** 成绩 */
		UserScore;

	}

	private final String TAG = JwglMain.class.getSimpleName();

	public void onCreate(Bundle bundle) {
		super.onCreate(bundle);
		setContentView(R.layout.jwgl_main);
		initConn();
		L.d(TAG, "onCreate" + getTaskId());
	}

	public void onDestroy() {
		super.onDestroy();
		if (null != sHttpClient) {
			sHttpClient.close();
		}
	}

	/**
	 * 创建连接
	 */
	private void initConn() {
		if (null == sHttpClient) {
			sHttpClient = HttpUtils.getHttpClient();
		}
	}

	public void showUserInfo(View view) {
		goDetail(JwglContentType.UserInfo, null);
	}

	public void showSchedule(View view) {
		goDetail(JwglContentType.Schedule, null);
	}

	public void showScore(View view) {
		goDetail(JwglContentType.UserScore, null);
	}

	/**
	 * 跳转到指定类型的页面
	 * 
	 * @param type
	 *            页面类型
	 * @param data
	 *            传递的数据
	 */
	private void goDetail(JwglContentType type, Bundle data) {
		Bundle bundle = new Bundle();
		bundle.putSerializable(JWGL_CONTENT_INTENT_TYPE, type);
		// bundle.putBundle(JWGL_CONTENT_INTENT_DATA, data);
		startActivity(JwglDetail.class, bundle);
	}

}
